package com.whfc.mach.service;

import com.whfc.common.exception.BizException;
import com.whfc.common.result.ListData;
import com.whfc.common.result.PageData;
import com.whfc.entity.dto.msg.AppWarnMsgRecDTO;
import com.whfc.mach.dto.AppMachDTO;
import com.whfc.mach.dto.warn.AppMachWarnCountDTO;
import com.whfc.mach.dto.warn.AppWarnDetailDTO;
import com.whfc.mach.dto.warn.AppWarnMachRecordDTO;
import com.whfc.mach.dto.warn.AppWarnRuleDTO;
import com.whfc.mach.param.warn.*;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 设备报警
 *
 * @author sun_guodong
 * @date 2021-08-04
 */
public interface AppMachWarnService {
    /**
     * 统计报警数
     *
     * @param deptId
     * @param state
     * @param startTime
     * @param endTime
     * @return
     * @throws BizException
     */
    AppMachWarnCountDTO warnNumStatic(Integer deptId, Integer state, Date startTime, Date endTime) throws BizException;   /**
     * 统计报警数新版
     *
     * @param deptId
     * @param state
     * @param startTime
     * @param endTime
     * @return
     * @throws BizException
     */
    Map<Integer,Integer> warnNumStaticV2(Integer deptId, Integer state, Date startTime, Date endTime) throws BizException;

    /**
     * 报警规则列表
     *
     * @param pageNum
     * @param pageSize
     * @param ruleType
     * @param keyword
     * @param deptId
     * @param enableFlag
     * @return
     * @throws BizException
     */
    PageData<AppWarnRuleDTO> ruleList(Integer pageNum, Integer pageSize, Integer ruleType, String keyword, Integer deptId, Integer enableFlag) throws BizException;

    /**
     * @param ruleId
     * @throws BizException
     */
    void ruleDel(Integer ruleId) throws BizException;

    /**
     * 启用禁用/报警规则
     *
     * @param request
     * @throws BizException
     */
    void enable(AppWarnEnableParam request) throws BizException;

    /**
     * 添加报警规则
     *
     * @param request
     * @throws BizException
     */
    void ruleAdd(AppWarnRuleAddParam request) throws BizException;

    /**
     * 编辑报警规则
     *
     * @param request
     * @throws BizException
     */
    void ruleEdit(AppWarnRuleEditParam request) throws BizException;

    /**
     * 设置报警时间
     *
     * @param request
     * @throws BizException
     */
    void setTime(AppWarnSetTimeParam request) throws BizException;

    /**
     * 消息接受人列表
     *
     * @param ruleId
     * @return
     * @throws BizException
     */
    AppWarnMsgRecDTO userList(Integer ruleId) throws BizException;

    /**
     * 添加消息接受人
     *
     * @param request
     * @throws BizException
     */
    void userAdd(AppWarnSetUserParam request) throws BizException;

    /**
     * 查找已设置的报警对象
     *
     * @param ruleId
     * @return
     * @throws BizException
     */
    ListData<AppMachDTO> objectList(Integer ruleId) throws BizException;

    /**
     * 查找可供选择的报警对象
     *
     * @param ruleId
     * @return
     * @throws BizException
     */
    ListData<AppMachDTO> getMachList(Integer ruleId) throws BizException;

    /**
     * 设置报警对象
     *
     * @param request
     * @throws BizException
     */
    void objectAdd(AppWarnMachAddParam request) throws BizException;

    /**
     * 报警记录
     *
     * @param pageNum
     * @param pageSize
     * @param deptId
     * @param state
     * @param ruleType
     * @param startTime
     * @param endTime
     * @return
     * @throws BizException
     */
    PageData<AppWarnMachRecordDTO> recordList(Integer pageNum, Integer pageSize, Integer deptId, Integer state, Integer ruleType, Date startTime, Date endTime) throws BizException;

    /**
     * 处理报警
     *
     * @param request
     * @throws BizException
     */
    void recordHandle(AppWarnHandleParam request) throws BizException;

    /**
     * 批量处理报警
     *
     * @param param
     * @throws BizException
     */
    void batchHandle(AppWarnBatchHandleParam param) throws BizException;

    /**
     * 删除报警
     *
     * @param param
     * @throws BizException
     */
    void del(AppWarnBatchDelParam param) throws BizException;

    /**
     * 报警记录详情
     *
     * @param id
     * @return
     * @throws BizException
     */
    AppWarnDetailDTO recordDetail(Integer id) throws BizException;

    /**
     * 查询报警数
     *
     * @param deptIds
     * @param startTime
     * @param endTime
     * @return
     * @throws BizException
     */
    Integer getWarnNum(List<Integer> deptIds, Date startTime, Date endTime) throws BizException;

    /**
     * 查询报警记录中的报警类型
     *
     * @param machIds
     * @param ruleTypes
     * @param startTime
     * @param endTime
     * @return
     * @throws BizException
     */
    List<Integer> getWarnRuleTypeList(List<Integer> machIds, List<Integer> ruleTypes, Date startTime, Date endTime) throws BizException;

    /**
     * 国网报警记录
     *
     * @param machIds
     * @param ruleTypes
     * @param startTime
     * @param endTime
     * @param pageNum
     * @param pageSize
     * @return
     * @throws BizException
     */
    PageData<AppWarnMachRecordDTO> getMachWarnList(List<Integer> machIds, List<Integer> ruleTypes, Date startTime, Date endTime, Integer pageNum, Integer pageSize) throws BizException;

}
